<?php
$reg = "/(http[s]?:\/\/.*?)\//i";
if (isset($_SERVER['HTTP_REFERER']))
{
	$src = $_SERVER['HTTP_REFERER'];
	preg_match($reg, $src, $match);
	$httpUrl = $match[1];
}
else if (isset($_SERVER['HTTP_ORIGIN']))
{
	$httpUrl = $_SERVER['HTTP_ORIGIN'];
}else{
	$httpUrl = $_SERVER['HTTP_HOST'];
}

if (isWhiteDomain($httpUrl))
{
	header('Access-Control-Allow-Credentials:true');
	header('Access-Control-Allow-Origin:' . $httpUrl);
	header('Access-Control-Allow-Methods:GET');
	header('Access-Control-Allow-Headers:x-requested-with,content-type');
}
else
{//错误
	header('Access-Control-Allow-Origin:http://www.qilaiwan.cn/');
}

